#ifndef CORE_H
#define CORE_H

#include "Framelistener.h"
#include "Image.h"
#include <SDL.h>

#include <list>
#include <utility>
#include <string>

class Core
{
    public:
        void Init(int resX, int resY, int bpp, int opts = SDL_HWSURFACE | SDL_DOUBLEBUF);
        static Core* GetInstancePtr();
        static Core& GetInstance();
        void AddFrameListener(FrameListener* listener);
        void RemoveFrameListener(FrameListener* listener);
        static void Draw(Image* image, int posX, int posY);
        static void Draw(Image* image, const SDL_Rect& r);
        void StartRender();
        static Image* Load(const std::string& file);
        static Image* Load(SDL_Surface* file);
        static void Unload(Image* image);
        void ClearScreen(int r = 0, int g = 0, int b = 0);
        ~Core();
    protected:
    private:
    Core();
    static Core mInstance;
    std::list<FrameListener*> FrameListeners;
    std::list<FrameListener*>::iterator FrameListenersIterator;
    std::list<FrameListener*> RemoveFrameListeners;
    static std::list<std::pair<Image*,SDL_Rect> > ImageToDraw;
/*
    Timer mTimer;
    Timer mFPS;
*/
    float initTime;
    float endTime;
    float tickPerFrame;
    float timeSecond;
    int FPS;
    static std::list<Image*> mImageList;

};

#endif // CORE_H
